package org.bookshare.document.navigation;

import org.benetech.collections.IdTree;
import org.jdom.Element;

public class GenericNavigationElement implements NavigationElement {

	public IdTree<Element, String, String> delegate;
	private NavigationElementType type;
	private String text;

	public GenericNavigationElement(final IdTree<Element, String, String> delegate, final NavigationElementType type) {
		this.delegate = delegate;
		this.type = type;
	}

	public Element getElement() {
	    return delegate.getContent();
    }

	public String getId() {
		return delegate.getId();
    }

	private IdTree<Element, String, String> getDelegate() {
		return delegate;
	}

	public int getDistanceFrom(NavigationElement otherElement) {
		if (otherElement instanceof GenericNavigationElement) {
			return Math.abs(delegate.getDistanceFrom(((GenericNavigationElement)otherElement).getDelegate()));
		} else {
			// XXX
			throw new RuntimeException("I don't know how to find the distance to that element");
		}
	}


	public String getText() {
		return text;
    }

	public void setText(String text) {
		this.text = text;
	}

	public NavigationElementType getType() {
	    return type;
    }

}
